<%@ page language="java" pageEncoding="UTF-8" %>
	<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
		<!DOCTYPE html>
		<html>

		<head>
			<title>后台管理</title>
			<meta charset="utf-8" />
			<base href="${pageContext.request.contextPath}/">
			<link rel="stylesheet" href="css/admin.css" />
			<script src="../js/jquery-3.6.0.js"></script>
			<script src="../js/jquery-form.js" type="text/javascript"></script>
			<script src="../js/template.js"></script>
			<script src="/layer/layer.js"></script>
			<script type="text/javascript" src="ueditor/ueditor.config.js"></script>
			<script type="text/javascript" src="ueditor/ueditor.all.js"></script>

			<script type="text/javascript">
				window.addEventListener("load", function () {
					var ue = UE.getEditor('container', {
						toolbars: [[
							'fullscreen', 'source', '|', 'undo', 'redo', '|',
							'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
							'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
							'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
							'directionalityltr', 'directionalityrtl', 'indent', '|',
							'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
							'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
							'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
							'print', 'preview', 'searchreplace', 'drafts', 'help'
						]]
						, initialFrameWidth: 1000
					});
				});

			</script>
		</head>

		<body>
			<div class="container">
				<div id="header">
					<jsp:include page="header.jsp"></jsp:include>
				</div>
				<div id="admin_left">
					<ul class="submenu">
						<jsp:include page="left.jsp"></jsp:include>
					</ul>
					<div id="copyright"></div>
				</div>

				<div id="admin_right">
					<div class="content_box" style="height: 640px;">
						<div class="content form_content">
							<form action="admin/goods?opr=add" method="post" enctype="multipart/form-data" id="addform">
								<div id="table_box_1">
									<table class="form_table">
										<colgroup>
											<col width="150px">
											<col>
										</colgroup>
										<tbody>
											<tr>
												<th>商品名称：</th>
												<td><input class="normal" name="name" type="text" value=" "
														id="name"><label>*</label></td>
											</tr>
											<tr>
												<th>ISBN：</th>
												<td><input class="normal" name="ISBN" type="text" value=""
														id="ISBN"><label>*</label></td>
											</tr>
											<tr>
												<th>作者：</th>
												<td><input class="normal" name="author" type="text" value=""
														id="author"><label>*</label></td>
											</tr>
											<tr>
												<th>出版社：</th>
												<td><input class="normal" name="publisher" type="text" value=""
														id="publisher"><label>*</label></td>
											</tr>
											<tr>
												<th>出版时间：</th>
												<td><input class="normal" name="pubTime" type="text" value=""
														id="pubTime"><label>*</label></td>
											</tr>
											<tr>
												<th>所属分类：</th>
												<td><select name="categoryId">
														<c:forEach items="${categories}" var="category">
															<option value="${category.id}">${category.categoryName}
															</option>
														</c:forEach>

													</select></td>
											</tr>
											<tr>
												<th>基本数据：</th>
												<td>
													<div class="con">
														<table class="border_table">
															<thead id="goodsBaseHead">
																<tr>
																	<th>销量</th>
																	<th>库存</th>
																	<th>市场价格</th>
																	<th>销售价格</th>
																</tr>
															</thead>
															<tbody id="goodsBaseBody">
																<tr class="td_c">
																	<td><input class="small" name="salesNum" type="text"
																			value="" id="salesNum" /></td>
																	<td><input class="tiny" name="stock" type="text"
																			id="stock">
																	</td>
																	<td><input class="tiny" name="marketPrice"
																			type="text" id="marketPrice"></td>
																	<td><input class="tiny" name="salesPrice"
																			type="text" id="salesPrice"></td>
																</tr>
															</tbody>
														</table>
													</div>
												</td>
											</tr>
											<tr>
												<th>缩略图：</th>
												<td><input type="file" name="file" id="file" /></td>
											</tr>
											<tr>
												<th>产品描述：</th>
												<td>
													<script id="container" name="description"
														type="text/plain">这里写你的初始化内容</script>
												</td>
											</tr>
											<tr>
												<th>最新，热卖</th>
												<td>是否最新：<input type="checkbox" name="newest" value="1" />
													是否热卖：<input type="checkbox" name="hot" value="1" /></td>
											</tr>
										</tbody>
									</table>
								</div>
								<table class="form_table" style="margin-top: -10px;">
									<colgroup>
										<col width="150px">
										<col>
									</colgroup>
									<tbody>
										<tr>
											<td></td>
											<td><button class="submit" type="button">
													<span>发布商品</span>
												</button></td>
										</tr>
									</tbody>
								</table>
							</form>
						</div>
					</div>
				</div>
				<div id="separator"></div>
			</div>
			<script>
				$(function () {
					// 记录验证通过数
					var list = new Array();
					list[0] = 1;
					list[1] = 1;
					list[2] = 1;
					list[3] = 1;
					list[4] = 1;
					$("#name").blur(function () {
						if ($(this).val().trim() == '') {
							$(this).next().text("必填项");
							$(this).next().prop("style").color = "red";
							$(this).prop("style").backgroundColor = "rgb(244, 169, 155)";
							list[0] = 1;
						} else {
							$(this).next().text("验证通过");
							$(this).next().prop("style").color = "rgb(18, 157, 81)";
							$(this).prop("style").backgroundColor = "aquamarine";
							list[0] = 0;
						}
					}),
						$("#ISBN").blur(function () {
							if ($(this).val().trim() == '') {
								$(this).next().text("必填项");
								$(this).next().prop("style").color = "red";
								$(this).prop("style").backgroundColor = "rgb(244, 169, 155)";
								list[1] = 1;
							} else {
								$(this).next().text("验证通过");
								$(this).next().prop("style").color = "rgb(18, 157, 81)";
								$(this).prop("style").backgroundColor = "aquamarine";
								list[1] = 0;
							}
						}),
						$("#author").blur(function () {
							if ($(this).val().trim() == '') {
								$(this).next().text("必填项");
								$(this).next().prop("style").color = "red";
								$(this).prop("style").backgroundColor = "rgb(244, 169, 155)";
								list[2] = 1;
							} else {
								$(this).next().text("验证通过");
								$(this).next().prop("style").color = "rgb(18, 157, 81)";
								$(this).prop("style").backgroundColor = "aquamarine";
								list[2] = 0;
							}
						}),
						$("#publisher").blur(function () {
							if ($(this).val().trim() == '') {
								$(this).next().text("必填项");
								$(this).next().prop("style").color = "red";
								$(this).prop("style").backgroundColor = "rgb(244, 169, 155)";
								list[3] = 1;
							} else {
								$(this).next().text("验证通过");
								$(this).next().prop("style").color = "rgb(18, 157, 81)";
								$(this).prop("style").backgroundColor = "aquamarine";
								list[3] = 0;
							}
						}),
						$("#pubTime").blur(function () {
							if ($(this).val().trim() == '') {
								$(this).next().text("必填项");
								$(this).next().prop("style").color = "red";
								$(this).prop("style").backgroundColor = "rgb(244, 169, 155)";
								list[4] = 1;
							} else {
								$(this).next().text("验证通过");
								$(this).next().prop("style").color = "rgb(18, 157, 81)";
								$(this).prop("style").backgroundColor = "aquamarine";
								list[4] = 0;
							}
						}),
						$(".submit").click(function () {
							console.log(list)
							if (list[0] == 0 && list[1] == 0 && list[2] == 0 && list[3] == 0 && list[4] == 0) {
								$("#addform").submit();
							} else {
								layer.msg('验证未通过', function () {
									//关闭后的操作
								});
							}
						})
				})
			</script>
		</body>

		</html>